const jwt = require('jwt-simple');

const secret = 'qwertyuiopasdfghjklzxcvbnm';

//生成token
const getToken=(payload={})=>{
  //设置token失效时间
  payload.exp=Math.floor(Date.now()/1000)+30*60
  return jwt.encode(payload,secret)
}

//验证token
const verifyToken=token=>{
  return jwt.decode(token,secret)
}

module.exports={
  getToken,
  verifyToken
}